
#include "_hpp/cqthread.hpp"
#include "_hpp/extinit.hpp"

using namespace cq;
using namespace std;

bool trdsign = nullptr;
std::shared_ptr<CQThread> cqtrd_ptr(new CQThread());

CQ_INIT {

    //using Message = cq::message::Message;
    //using MessageSegment = cq::message::MessageSegment;

    on_enable([] {

        robotinit();

        trdsign = false;
        thread trd = std::thread(*cqtrd_ptr.get(),std::ref(trdsign));
        trd.detach();
    });

    on_disable([] { 
        trdsign = !trdsign;
        
    });

    on_private_message([](const PrivateMessageEvent &event) {

        if (message::Message(event.message).extract_plain_text() == "?") {
            ; // 查询权限处理 还有某个人要求的完全反馈
        } else if (event.user_id == RCFG.ROBOTADMIN or RCFG.PSEUDOADMINS.count(event.user_id) not_eq 0)
            ; // 这里可以不push 但是需要设置一个条件防恶意
    });

    on_group_message([](const GroupMessageEvent &event) {

        ; // 线程push处理
    });
}

CQ_MENU(config_menu) { /* reload_menu extupdate_menu */

    string command = "notepad " + ::utils::ansi(::get_app_directory() + "config.json");
    WinExec(command.c_str(), SW_RESTORE);

    //nana::msgbox msg{"emmm"};
    //msg << "喂！你点我干嘛?";
    //msg.show();

    /*#include <nana/gui/widgets/label.hpp>
     using namespace nana;
     form fm;
     label lb{fm, rectangle{10, 10, 100, 100}};
     lb.caption("Hello, world!");
     fm.show();
     exec();*/
}